<?php

namespace App\Services\Dao;

use App\Model\Sign;
use Hyperf\Database\Model\Builder;
use Hyperf\Database\Model\Collection;
use Hyperf\Database\Model\Model;

class SignDao
{
    /**
     * @param int $meetingId
     * @param int $userId
     * @param int $type
     * @return Builder|Model|object|null
     */
    public function first(int $meetingId, int $userId, int $type = Sign::TYPE_IN)
    {
        return Sign::query()->where('meeting_id', $meetingId)
            ->where('user_id', $userId)
            ->where('type', $type)
            ->first();
    }

    /**
     * @param int $userId
     * @return Builder[]|Collection
     */
    public function findTakePartIn(int $userId)
    {
        return Sign::query()->where('user_id', '=', $userId)->get();
    }
}